mirror your GitHub repos to tangled.org automatically
1

Configure Feed

Select the types of activity you want to include in your feed.

1import { and, eq } from 'drizzle-orm' 2import { repoMapping } from '#server/db/schema' 3import { useDb } from '#server/utils/db' 4import { enqueue } from '#server/utils/queue' 5import { requireSession } from '#server/utils/server-session' 6 7/** 8 * Enqueue a forced `tangled.create-repo` job for one mapping. The handler 9 * normally no-ops when a mapping already exists; the `force: true` envelope 10 * flag tells it to re-run the enrolment flow. 11 */ 12export default defineEventHandler(async event => { 13 const session = await requireSession(event) 14 const mappingId = Number(getRouterParam(event, 'id')) 15 if (!Number.isFinite(mappingId)) { 16 throw createError({ statusCode: 400, statusMessage: 'invalid mapping id' }) 17 } 18 19 const db = useDb() 20 const rows = await db.select({ 21 githubRepoId: repoMapping.githubRepoId, 22 }) 23 .from(repoMapping) 24 .where(and( 25 eq(repoMapping.id, mappingId), 26 eq(repoMapping.installationId, session.installationId), 27 )) 28 .limit(1) 29 if (rows.length === 0) { 30 throw createError({ statusCode: 404, statusMessage: 'mapping not found' }) 31 } 32 33 const row = await enqueue('tangled.create-repo', { 34 installationId: session.installationId, 35 githubRepoId: rows[0]!.githubRepoId, 36 force: true, 37 }) 38 return { jobId: row?.id ?? null } 39})